<?php
      require_once("../view/menu.php");
?>
<div id="content">
<div class="title">Specjalizacja dla kierunku:
    <form action="<?php if(!empty($base_path)){echo $base_path."specialization";
                         }else{ echo "../specialization";}?>"method="GET">
        <select name="direction" onchange="submit()">
            <?php foreach($directions as $direction){
                    echo '<option value='.$direction['id'];
                    if(isset($direction_selected) && $direction_selected == $direction['id'])
                        echo ' selected="selected"';
                    echo '>'. $direction['nazwa'] .'</option>';} ?>
        </select>
    </form>
</div>
<div>

    Dodaj nową specjalizacje:
    <form action="<?php if(!empty($base_path)){echo $base_path."specialization?direction=".$direction_selected;
                         }else{ echo "../specialization?direction=".$direction_selected;}?>"method="POST">
        <input name="spec" type="input" />
        <input type="hidden" name="action" value="add" />
        <input type="hidden" name="kierunek" value=<?php echo $direction_selected; ?> />
        <input type="submit" value="Dodaj" />
    </form>
<br />
    <table id="edit_table">
      <tr class="title">
          <th> Specjalizacja</th>
          <th> Edytuj</th>
          <th> Usuń</th>    
     </tr>
    <?php foreach($specialization as $key=>$spec):?>
     <?php if($key%2){echo "<tr style='background-color:#FFF0DF'>";}
           else{echo "<tr>";}?>
            <td><?php echo $spec['nazwa']; ?></td>
            <td class="button">
                <form action="<?php if(!empty($base_path)){echo $base_path."specialization?direction=".$direction_selected;
                         }else{ echo "../specialization?direction=".$direction_selected;}?>" method="POST">
                    <input type="hidden" name="spec_id" value="<?php echo $spec['id']; ?>" />
                    <input type="hidden" name="action" value="edit" />
                    <input type="submit" value="Edytuj"/>
                </form>
            </td>
            <td class="button">
                <form action="<?php if(!empty($base_path)){echo $base_path."specialization?direction=".$direction_selected;
                         }else{ echo "../specialization?direction=".$direction_selected;}?>" method="POST">
                    <input type="hidden" name="spec_id" value="<?php echo $spec['id']; ?>" />
                    <input type="hidden" name="action" value="delete" />
                    <input type="submit" value="Usuń"/>
                </form>
            </td>
        </tr>
    <?php endforeach;?>
    </table> 
</div>
</div>
<?php
      require_once("../view/footer.php");
?>